﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using System.Data.SqlClient;

public partial class UserControl_TransArrangeReport : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        DataSet transArrage = new DataSet();
        SqlDataAdapter sda = new SqlDataAdapter();
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BookShop"].ConnectionString);
        conn.Open();
        string alloc_id;
        alloc_id = ((HiddenField)((System.Web.UI.Page)System.Web.HttpContext.Current.Handler).FindControl("alloc_id")).Value;

        sda = new SqlDataAdapter("SELECT AllocationID, AllocationDate,StoreID,ShippedDate,ShipVia,Status From Allocation where AllocationID = '" + alloc_id + "' and Status = 'ready'", conn);
        sda.Fill(transArrage, "Allocation");

        sda = new SqlDataAdapter("SELECT AllocationID,ISBN,StoreID,AllocationDetailID,Amount From AllocationDetail where AllocationID = '" + alloc_id + "'", conn);
        sda.Fill(transArrage, "AllocationDetail");

        sda = new SqlDataAdapter("SELECT BookName,ISBN,Author, Publisher From Book", conn);
        sda.Fill(transArrage, "Book");

        sda = new SqlDataAdapter("SELECT StoreID,Name,Address From Store", conn);
        sda.Fill(transArrage, "Store");

        sda = new SqlDataAdapter("SELECT ShipperID,CompanyName,Phone FROM Shipper", conn);
        sda.Fill(transArrage, "Shipper");

        ReportDocument TransReport = new ReportDocument();
        string repPath = Server.MapPath("~/Reports/TransArrangeReport.rpt");
        TransReport.Load(repPath);

        TransReport.SetDataSource(transArrage);
        CrystalReportViewer1.ReportSource = TransReport;
    }
}
